﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Assignment4
{
    class Example
    {
        //Static methods and variables
        public static Dictionary<string, List<string>> AttributeCollection = new Dictionary<string, List<string>>();
        public static List<string> ActionCollection = new List<string>();

        private string name;
        /// <summary>
        /// Example's name
        /// </summary>
        public string Name
        {
            get { return name; }
            set { name = value; }
        }

        private string action;

        public string Action
        {
            get { return action; }
            set { action = value; }
        }

        private Dictionary<string, string> attributes;

        public Example(string name)
        {
            this.Name = name;
            attributes = new Dictionary<string, string>();
        }

        /// <summary>
        /// Add an attribute to example
        /// </summary>
        /// <param name="attributeType">Name of attribute</param>
        /// <param name="attributeValue">Attribute value</param>
        public void addAttribute(string attributeType, string attributeValue)
        {
            try
            {
                attributes.Add(attributeType, attributeValue);
            }
            catch (ArgumentException)
            {
                Console.WriteLine("Attribute {0} already exists in example {1}", attributeType, this.Name);
                Console.ReadLine();
                Environment.Exit(0);
            }
        }

        /// <summary>
        /// Get attribute value correspondent to its name
        /// </summary>
        /// <param name="attributeType">Attribute's name</param>
        /// <returns>Attribute value in this example</returns>
        public string getValue(string attributeType)
        {
            string value;
            if (attributes.TryGetValue(attributeType, out value))
            {
            }
            else
            {
                Console.WriteLine("Attribute {0} doesn't exist in example {1}", attributeType, this.Name);
                Console.ReadLine();
                Environment.Exit(0);
            }
            return value;
        }
    }
}
